package com.iussoft.gateway.protocol;

import com.apache.tools.StrUtil;
import com.iussoft.tools.LoggerUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

/**
 * @description: socket服务启动监听
 * @author: Hou Dayu
 * @date: Created in 2020/3/13
 */
@Configuration
public class SocketConfig {

    @Autowired
    private Environment env;

    @Bean
    public GatewaySocketListener startSocketPortListener() {
        String socketPort = StrUtil.doNull(env.getProperty("rpc.service.port"), "8843");
        LoggerUtil.info("rpc.service.port->"+socketPort);
        GatewaySocketListener listener = new GatewaySocketListener(socketPort);
        return listener;
    }

}
